import { Button } from 'antd';
import { useRef } from 'react';

import DxForm from '@/components/DxForm/DxForm';
import { FieldItem } from '@/components/DxForm/useForm';

const fields: FieldItem[] = [
  { label: '用户名', prop: 'username', widget: 'input' },
  { label: '密码', prop: 'password', widget: 'input' },
  {
    label: '性别',
    prop: 'sex',
    widget: 'select',
    props: {
      options: [
        { label: '男', value: 'male' },
        { label: '女', value: 'female' },
      ],
    },
  },
];
export default function TodosApp() {
  const refModel = useRef<Record<string, any>>({});
  return (
    <div>
      <DxForm fields={fields} model={refModel.current}></DxForm>
      <Button
        type="primary"
        onClick={() => {
          console.log(refModel.current);
        }}
      >
        确认
      </Button>
    </div>
  );
}
